<template>
    <h3 style="text-align: center;" >
        登录页面
    </h3>
    <table class="table table-bordered" border="1">
        <tr>
            <td>
                用户名
            </td>
            <td>
                <input type="text"  v-model="Info.F_name" placeholder="请输入用户名">
            </td>
        </tr>
        <tr>
            <td>
                密码
            </td>
            <td>
                <input type="password"  v-model="Info.F_pwd" placeholder="请输入密码">
            </td>
        </tr>
        <tr style="text-align: center;">
            <td colspan="2">
                <button class="btn btn-primary" @click="Adduser">登录</button>
            </td>
        </tr>
    </table>
</template>
<script setup lang="ts">
import {useStore}from '../../store/index.ts'
const store=useStore()
import { useRouter } from 'vue-router';
const router = useRouter();
import { ref } from 'vue';
//双向绑定注册
const Info=ref({
    F_id:0,
    F_name:'',
    F_pwd:'',
    F_date:'',
})
import axios from 'axios';
//登录
const Adduser=()=>{
    axios.get('https://localhost:44369/api/Financs/FLogin',
    {
       params:{
           F_name:Info.value.F_name,
           F_pwd:Info.value.F_pwd
       }
    }).then((res)=>{
        if(res.data!=null)
        {
            store.F_id=res.data.F_id
            alert("登陆成功")
            QCher(res.data.F_id)
        }
        else{
            alert("登陆失败")
        }
       console.log(res.data)
    })
}
///查询身份是啥
const QCher=(F_id:number)=>{
    
    axios.get('https://localhost:44369/api/Financs/SHowUserxx',
    {
       params:{
           F_id:F_id
       }
    })
    .then((res)=>{
        console.log(res.data)
        if(res.data[0].F_ULname=="普通用户")
        {
            router.push({
                path:'/ShowYonghCherg'
            
            })
        }
        else{
            router.push({
                path:'/ShowGlyuan'

            })
        }

        
    })
        
    
}

</script>